﻿@model IPagedList<Actya.Core.SiteStructure.Page>
@{
	ViewBag.Title = "Pages";
}

@section help
{
	Manage the pages. Each page uses a specific page layout that determines the look and feel and the content type.
}

<h2>@ViewBag.Title</h2>

<ul class="listview">
	@foreach (var page in Model) {
		var pageLayout = this.CmsContext.Site.GetPageLayoutById(page.Layout);
		var layoutName = pageLayout != null ? pageLayout.Name : "unknown";
		var pageUrl = !String.IsNullOrEmpty(this.CmsContext.Host.Settings.PagesPrefix)
		              	? string.Format("/{0}{1}", this.CmsContext.Host.Settings.PagesPrefix, page.Url)
		              	: page.Url;
		<li>
			<span class="item-title">@page.Title</span>
			@pageUrl
			<div class="item-sub">
				@if (page.IsPublished)
				{
					<span class="published">Published</span>
				}
				else
				{
					<span class="unpublished">Unpublished</span>
				}
				Layout: <span class="item-value">@layoutName</span>
				Last modified: <span class="item-value">@page.DateModified</span> by <span class="item-value">@page.ModifiedBy</span>
			</div>
			<div class="item-cmds">
				@Html.ActionLink("Edit", "update", new { id = page.Id }, new { @class = "cmd" })
				@using (Html.BeginForm("delete", "Pages", new { id = page.Id }, FormMethod.Post, new { @class = "inline" })) {
					@Html.AntiForgeryToken()
					<a href="#" class="cmd deletelink">Delete</a>
				}
				@if (page.IsActive) {
					<a href="@Cms.AbsoluteUrl(page.Url)" class="cmd">View</a>
				}
				&nbsp;
			</div>
		</li>
	}
</ul>
<div class="pager">
	@Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount)
</div>

@section sidebar {
	<ul>
		<li>@Html.ActionLink("New page", "Create")</li>
	</ul>

}